package online.sixfish.doubao.listener;

import online.sixfish.doubao.event.ArticleViewEvent;
import online.sixfish.doubao.service.ArticleService;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ArticleListener {
    @Resource
    ArticleService articleService;

    @Async("executor")
    @EventListener
    public void handleArticleViewEvent(ArticleViewEvent event){
        articleService.viewIncrement(event.getArticleId());
    }
}
